package com.ld.common.config;

import java.util.Timer;
import java.util.TimerTask;

import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import com.ld.common.plugin.PluginManager;

import lombok.extern.slf4j.Slf4j;

/**
 * 启动完成后纸箱厂
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年7月8日 下午6:47:27
 *
 */
@Component
@Slf4j
public class ApplicationRunnerImpl implements ApplicationRunner {
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.warn("====================通过实现ApplicationRunner接口，在spring boot项目启动后执行====================");
        String[] sourceArgs = args.getSourceArgs();
        for (String arg : sourceArgs) {
            System.out.print(arg + " ");
        }
        log.warn("插件加载开始……");
        PluginManager.init(); // 插件初始化
        log.warn("插件加载完成！");
        // 异步加载插件,true设为守护线程
        new Timer(true).schedule(new TimerTask() {
            @Override
            public void run() {
            }
        }, 100);

        System.out.println();
    }
}